<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Seleksi extends CI_Controller {
	
	function __construct(){
		parent::__construct();
		$this->load->model('mdl_seleksi');
		//$this->output->enable_profiler(TRUE);
	}
	
	function index(){
		$this->load->view('pmb/seleksi');
	}
	
	function getdata(){
		// get post
		$data['PMBPeriodID'] = $this->input->post('PMBPeriodID');
		$data['jumlah'] = $this->input->post('jumlah');
		
		echo $this->mdl_seleksi->getdata($data);
	}
	
	function save(){
		# init
		$status = "";
		$result = false;
		$data['pesan_error'] = '';
		
		# get post data
		foreach($_POST as $key => $value){
			$data[$key] = $value;
		}
		
		$data['pesan_error'] = '';
		
		$result=$this->mdl_seleksi->InsertOnDB($data['data']);
		
		if($result){
			echo json_encode(array('success'=>true));
		}else{
			echo json_encode(array('msg'=>$data['pesan_error']));
		}
	}
	
}